<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:c="http://java.sun.com/jsp/jstl/core"> 
    <h:head>
        <title>SGP - Cadastro Projeto</title>
    </h:head>
    <h:body>
        <ui:insert name="header" >
            <ui:include src="cabecalho.xhtml" />
        </ui:insert>
        <div id="conteudo">
            <div id="conteudo-table-interno">
                <c:if test="#{beanCabecalho.idPermissao != 3}">
                    <hr /><br />
                    <h2>Inserir / Alterar</h2><br />
                    <hr /><br />
                    <h:form>
                        <table id="tabelaFormulario" border="0" cellpadding="0" cellspacing="2" align="center" width="98%">            
                            <tr>
                                <td align="right"><label><span class="obr">*</span> Empresa</label></td>
                                <td width="313">
                                    <div class="branco">
                                        <h:selectOneMenu id="cliente" value="#{beanCadastroProjeto.clienteSelecionado}" converter="simpleEntityConverter" style="width: 310px;" >
                                            <f:selectItem itemValue="" itemLabel="Selecione"/>
                                            <f:selectItems value="#{beanCadastroProjeto.listaClientes}" var="cliente" itemLabel="#{cliente.nomeEmpresa}" itemValue="#{cliente}" ></f:selectItems>
                                        </h:selectOneMenu><br /> 
                                   </div>
                                </td> 
                                <td align="right"><label><span class="obr">*</span> Nome do Projeto</label></td>
                                <td width="313">
                                    <div class="branco">
                                        <h:inputText value="#{beanCadastroProjeto.projeto.nomeProjeto}"/><br />
                                    </div>
                                </td> 
                            </tr>      
                             <tr>
                                <td align="right"><label><span class="obr">*</span> Ambiente</label></td>
                                <td width="313">
                                    <div class="branco">
                                        <h:selectOneMenu id="ambiente" value="#{beanCadastroProjeto.ambienteSelecionado}" converter="simpleEntityConverter"  style="width: 310px;" >
                                            <f:selectItem itemValue="" itemLabel="Selecione"/>
                                            <f:selectItems value="#{beanCadastroProjeto.listaAmbientes}" var="ambiente" itemLabel="#{ambiente.ambiente}" itemValue="#{ambiente}" ></f:selectItems>
                                        </h:selectOneMenu><br />
                                    </div>
                                </td>
                                <td align="right"><label><span class="obr">*</span> Estimativa de Entrega</label></td>
                                <td width="313">
                                    <div class="branco">
                                        <h:inputText value="#{beanCadastroProjeto.projeto.estimativaEntrega}"/><br />
                                    </div>
                                </td>
                            </tr>
                          <tr>
                                <td align="right"><label><span class="obr">*</span> Plataforma</label></td>
                                <td width="313">
                                    <div class="branco">
                                        <h:selectOneMenu id="plataforma" value="#{beanCadastroProjeto.plataformaSelecionada}"  converter="simpleEntityConverter" style="width: 310px;"  >
                                            <f:selectItem itemValue="" itemLabel="Selecione"/>
                                            <f:selectItems value="#{beanCadastroProjeto.listaPlataformas}" var="plataforma" itemLabel="#{plataforma.plataforma}" itemValue="#{plataforma}" ></f:selectItems>
                                        </h:selectOneMenu><br />
                                    </div>
                                </td>
                            </tr>
                             <tr>
                                <td colspan="2" align="left">
                                    <span class="obr">* Campos Obrigatórios</span>
                                </td>
                                <td colspan="2" align="right">
                                     <h:commandButton value="Cadastrar" class="botao" action="#{beanCadastroProjeto.cadastrarProjeto}" rendered="#{empty beanCadastroProjeto.id}"/>
                                     <h:commandButton value="Alterar" class="botao" action="#{beanCadastroProjeto.alterarProjeto()}" rendered="#{not empty beanCadastroProjeto.id}"/>
                                     <h:commandButton value="Novo" class="botao" action="#{beanCadastroProjeto.novoProjeto}" rendered="#{not empty beanCadastroProjeto.id}" />
                                </td>
                            </tr>
                        </table>
                    </h:form>
                    <div class="clear"></div>
                    <br />
                </c:if>
                <hr /><br />
                <h2>Listar</h2><br />
                <hr /><br />
                <h:form>
                    <h:dataTable id="dataTableCliente" class="dataTableCliente" cellpadding="0" cellspacing="1" var="projeto" value="#{beanCadastroProjeto.listaProjetos}"  >
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Nome da Atividade"/>
                            </f:facet>
                            <h:outputText value="#{projeto.nomeProjeto}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Cliente" />
                            </f:facet>
                            <h:outputText value="#{projeto.cliente.nomeCliente}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Ambiente" />
                            </f:facet>
                             <h:outputText value="#{projeto.ambiente.ambiente}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Plataforma" />
                            </f:facet>
                             <h:outputText value="#{projeto.plataforma.plataforma}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Estimativa de Entrega" />
                            </f:facet>
                             <h:outputText value="#{projeto.estimativaEntrega}" />
                        </h:column>
                        <c:if test="#{beanCabecalho.idPermissao != 3}">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="" />
                                </f:facet>
                               <h:commandLink action="#{beanCadastroProjeto.preparaAlteracao()}"><img src="img/editar.png"/></h:commandLink>
                            </h:column>

                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="" />
                                </f:facet>
                                <h:commandLink action="#{beanCadastroProjeto.excluirProjeto()}"><img src="img/excluir.png" /></h:commandLink>
                            </h:column>
                        </c:if>
                    </h:dataTable>
                </h:form>
            </div>
        </div>     
    </h:body>
</html>
